package me.zhengjie.suli.tasks.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import me.zhengjie.suli.tasks.domain.TaskDetail;
import me.zhengjie.suli.tasks.repository.TaskDetailRepository;
import me.zhengjie.suli.tasks.service.TaskDetailService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Allen Gao
 * @website https://www.chinasuli.com.cn/
 * @description 服务实现
 * @date 2023-01-09
 **/
@Service
@RequiredArgsConstructor
public class TaskDetailServiceImpl implements TaskDetailService {
    private final TaskDetailRepository taskDetailRepository;
    @Override
    public List<TaskDetail> getTaskDetailsByTaskId(String id) {
        return taskDetailRepository.getTaskDetailsByTaskId(id);
    }

    @Override
    public List<TaskDetail> pdaGetTaskDetailsByTaskCode(String data) {
        JSONObject jsonObject = JSON.parseObject(data);
        String taskCode = jsonObject.getString("taskCode");
        List<TaskDetail> taskDetailList = taskDetailRepository.getTaskDetailsByTaskCode(taskCode);
        return taskDetailList;
    }
}
